#include <bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l>=n) cout<<n-1;
	else if(r%n<l%n) cout<<n-1;
	else cout<<r%n;
return 0;
}
